/*
 * @Author: Qimu
 * @Date: 2020-04-22 15:55:22
 * @LastEditors: Qimu
 * @LastEditTime: 2020-04-22 18:27:34
 * @Description: file content
 * @FilePath: \koa2_api\module\schama\lesson.js
 */

const mongoose = require('../db/mongodb');
const config = require('../config/config');

const lessonSchema = mongoose.Schema({
  lesson_img: {  //课程图片
    type: String,
    require: true,
  },
  lesson_name: { //课程名称
    type: String,
    require: true,
    trim: true
  },
  lesson_teacher: { //课程老师
    type: String,
    required: true,
    require: true,
  },
  lesson_type: { //课程类型
    type: String,
    required: true,
    require: true,
  },
  lesson_office: { //授课机构
    type: String,
    required: true,
    require: true,
  },
  lesson_site: { //授课地点
    type: String,
    required: true,
    require: true,
  },
  lesson_status: { //是否启用课程状态
    type: Number,
    default: 1
  },
  lesson_createTime: { //课程创建时间
    type: Date,
    default: Date.now
  },
  lesson_updateTime: { //课程更新时间
    type: Date,
    default: Date.now
  }
}, {
  timestamps: {
    createdAt: 'lesson_createTime',
    updatedAt: 'lesson_updateTime'
  }
})

module.exports = Lesson = mongoose.model('Lesson', lessonSchema, `${config.mongodb.table}lesson`);